import React from 'react';
import { Redirect } from 'react-router-dom';
import { Config } from './types';
import configs from './config';

const deepConfig = (route: Config) => {
  const { routes = [], redirect } = route;
  if (routes.length) {
    return routes.forEach(deepConfig)
  }
  if (redirect) route.render = () => (
    <Redirect to={redirect} />
  )
}

configs.map((config: Config) => deepConfig(config));

export default configs;
